const TimeRender = (props: any) => {
  const timeData = props.time
  let renderData
  let absData
  let months
  let monthsData
  let days
  let daysData
  let hours 
  let hoursData
  if (+timeData < 0) {
    absData = 0 - +timeData
    months = parseInt(String(absData / 30))
    if (months !== 0) {
      monthsData = `${months}个月`
    } else if(months === 0) {
      monthsData = ''
    }
    days = Math.floor(absData%30)
    if (days !== 0) {
      daysData = `${days}天`
    } else if (days === 0) {
      daysData = ''
    }
    hours = ((absData - Math.floor(absData)) * 24).toFixed()
    if (+hours !== 0) {
      hoursData = `${hours}小时`
    } else if(+hours === 0) {
      hoursData = ''
    }
    renderData = <span style={{color: '#FB9F5E'}}>{`超${monthsData}${daysData}${hoursData}`}</span>
  } 
  else {
    absData = +timeData
    months = parseInt(String(absData / 30))
    if (months !== 0) {
      monthsData = `${months}个月`
    } else if(months === 0) {
      monthsData = ''
    }
    days = Math.floor(absData%30)
    if (days !== 0) {
      daysData = `${days}天`
    } else if (days === 0) {
      daysData = ''
    }
    hours = ((absData - Math.floor(absData)) * 24).toFixed()
    if (+hours !== 0) {
      hoursData = `${hours}小时`
    } else if(+hours === 0) {
      hoursData = ''
    }
    renderData = <span style={{color: '#989898'}}>{`${monthsData}${daysData}${hoursData}`}</span>
  }
  return renderData
}

export default TimeRender
